﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package GameMode {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import Engine.Helpers.*;
    import Classes.*;
    import Modules.guide.ui.*;
    import Engine.*;

    public class GMPlaceBizOnLotSite extends GMPlaceMapResource {

        protected var m_lotObject:Sprite;
        protected var m_lotArrow:GuideArrow;

        public function GMPlaceBizOnLotSite(_arg1:LotSite, _arg2:String, _arg3:Class, _arg4:Boolean=false){
            this.m_lotObject = new Sprite();
            m_selectedLotSite = _arg1;
            super(_arg2, _arg3, _arg4);
        }
        override public function enableMode():void{
            if (m_selectedLotSite){
                m_selectedLotSite.alpha = 0;
            };
            GlobalEngine.viewport.overlayBase.addChild(this.m_lotObject);
            var _local1:String = Global.getAssetURL("assets/hud/tutorialArrow.swf");
            var _local2:Point = IsoMath.tilePosToPixelPos(Math.floor((m_selectedLotSite.getPosition().x + (2 * m_selectedLotSite.getSize().x))), Math.floor((m_selectedLotSite.getPosition().y + (2 * m_selectedLotSite.getSize().y))));
            this.drawFlatTileOutline(m_selectedLotSite);
            super.enableMode();
        }
        override public function disableMode():void{
            m_selectedLotSite.alpha = 1;
            if (Global.franchiseManager.placementMode){
                Global.franchiseManager.placementMode = false;
            };
            if (this.m_lotObject.parent == GlobalEngine.viewport.overlayBase){
                GlobalEngine.viewport.overlayBase.removeChild(this.m_lotObject);
            };
            Global.guide.removeArrows();
            this.m_lotArrow = null;
            super.disableMode();
        }
        override public function onMouseMove(_arg1:MouseEvent):Boolean{
            var _local2:Point;
            if (m_dragging){
                _local2 = IsoMath.tilePosToPixelPos(Math.floor((m_selectedLotSite.getPosition().x + m_selectedLotSite.getSize().x)), Math.floor((m_selectedLotSite.getPosition().y + m_selectedLotSite.getSize().y)));
                _local2 = IsoMath.viewportToStage(_local2);
                this.m_lotArrow.setPosition(_local2.x, _local2.y);
            };
            return (super.onMouseMove(_arg1));
        }
        protected function drawFlatTileOutline(_arg1:MapResource):void{
            this.m_lotObject.graphics.clear();
            var _local2:Vector3 = _arg1.getSize();
            this.m_lotObject.graphics.lineStyle((TILE_OUTLINE_WIDTH / 2), Constants.COLOR_VALID_PLACEMENT);
            this.m_lotObject.graphics.beginFill(0, 0);
            drawTileArea(this.m_lotObject.graphics, new Point(_arg1.getPosition().x, _arg1.getPosition().y), _local2.x, _local2.y);
            this.m_lotObject.graphics.endFill();
        }

    }
}//package GameMode 
